﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace StateMachineCompiler
{
	public abstract class StateMachineBuilder
	{
		private CommandChannel channel;
		private Controller controller;
		private StateMachine machine;

		public StateMachineBuilder(CommandChannel commandChannel)
		{
            this.channel = commandChannel;
			this.machine = CreateMachine();
			this.controller = new Controller(machine, commandChannel);
		}

		protected abstract StateMachine CreateMachine();

		public void Handle(string eventCode)
		{
			controller.Handle(eventCode);   
		}

        public IEnumerable<Transition> CurrentTransitions
        {
            get { return this.controller.CurrentState.Transitions; }
        }

        public string CurrentState
        {
            get { return this.controller.CurrentState.Name; }
        }
	}
}
